﻿<localControlsRelations:RelationBase x:Class="ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations.InheritanceRelation"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:localControlsRelations="clr-namespace:ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations"
    xmlns:localControlsMenu="clr-namespace:ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.ContextMenu"
    xmlns:localBindindingConverter="clr-namespace:ICSharpCode.Data.EDMDesigner.Core.UI.Converters"
    PreviewMouseDown="InheritanceRelationPreviewMouseDown"
    Focusable="True">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\SelectionRectangleResourceDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <localBindindingConverter:InheritanceRelationToVisibleConverter x:Key="InheritanceRelationToVisibleConverter" />
            <localBindindingConverter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <localBindindingConverter:DesignerInheritanceRelationToSelectionLocationConverter x:Key="DesignerInheritanceRelationToSelectionLocationConverter" />
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.ContextMenu>
        <localControlsMenu:ContextMenu>
            <localControlsMenu:MenuItem x:Name="deleteMenuItem" Header="{x:Static localControlsRelations:InheritanceRelation.DeleteText}" Command="{x:Static localControlsRelations:InheritanceRelation.DeleteCommand}" InputGestureText="Del">
                <localControlsMenu:MenuItem.Icon>
                    <Image Source="../../CSDLType/Resources/Delete.png" Width="16" Height="16" />
                </localControlsMenu:MenuItem.Icon>
            </localControlsMenu:MenuItem>
        </localControlsMenu:ContextMenu>
    </UserControl.ContextMenu>

    <UserControl.InputBindings>
        <KeyBinding Key="Delete" Command="{x:Static localControlsRelations:InheritanceRelation.DeleteCommand}" />
    </UserControl.InputBindings>

    <Grid>
        <Line x:Name="line" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X1, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X2, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y1, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y2, NotifyOnTargetUpdated=True}"/>
        <Line x:Name="line2" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X2, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X3, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y2, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y3, NotifyOnTargetUpdated=True}"
              Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Converter={StaticResource InheritanceRelationToVisibleConverter}}"/>
        <Line x:Name="line3" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X3, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X4, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y3, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y4, NotifyOnTargetUpdated=True}"
              Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Converter={StaticResource InheritanceRelationToVisibleConverter}}"/>
        <Line x:Name="lineArrow1" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X1Arrow, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X3Arrow, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y1Arrow, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y3Arrow, NotifyOnTargetUpdated=True}"/>
        <Line x:Name="lineArrow2" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X2Arrow, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X3Arrow, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y2Arrow, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y3Arrow, NotifyOnTargetUpdated=True}"/>
        <Line x:Name="lineArrow3" Stroke="Black" TargetUpdated="line_TargetUpdated"
              X1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X1Arrow, NotifyOnTargetUpdated=True}"
              X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=X2Arrow, NotifyOnTargetUpdated=True}"
              Y1="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y1Arrow, NotifyOnTargetUpdated=True}"
              Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=Y2Arrow, NotifyOnTargetUpdated=True}"/>
        <Rectangle x:Name="selectionRectangle1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Converter={StaticResource DesignerInheritanceRelationToSelectionLocationConverter}, ConverterParameter=1}" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=IsSelected, Converter={StaticResource BoolToVisibilityConverter}}" />
        <Rectangle x:Name="selectionRectangle2" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Converter={StaticResource DesignerInheritanceRelationToSelectionLocationConverter}, ConverterParameter=2}" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localControlsRelations:InheritanceRelation}}, Path=IsSelected, Converter={StaticResource BoolToVisibilityConverter}}" />
    </Grid>
</localControlsRelations:RelationBase>
